﻿using System.Collections.Generic;
using System;

namespace Comsenz.Services.Blocks.Configs
{
    /// <summary>
    /// 配置值
    /// </summary>
    /// <author>Chiron</author>
    public class SettingValue
    {
        #region Ctors
        /// <summary>
        /// 构建配置值
        /// </summary>
        public SettingValue()
        {
        }
        /// <summary>
        /// 构建配置值
        /// </summary>
        /// <param name="title">显示名</param>
        /// <param name="value">值</param>
        public SettingValue(string title, object value)
        {
            Title = title;
            Value = value;
        }
        #endregion Ctors

        #region Props
        private string title;
        /// <summary>
        /// 显示名
        /// </summary>
        public string Title
        {
            get
            {
                return title;
            }
            set
            {
                if (string.IsNullOrEmpty(value)) throw new ArgumentNullException("title");
                title = value;
            }
        }

        private object value;
        /// <summary>
        /// 值
        /// </summary>
        public object Value
        {
            get
            {
                return value;
            }
            set
            {
                if (value == null) throw new ArgumentNullException("value");
                this.value = value;
            }
        }
        #endregion Props


        /// <summary>
        /// 取得配置值
        /// </summary>
        /// <returns></returns>
        public Dictionary<object, object> GetConfigValue()
        {
            return new Dictionary<object, object>
            {
                {"0",Value},
                {"1",Title}
            };
        }
    }
}
